#!/bin/sh
/usr/local/bin/mysql -u test -pGim9p6gW test -e "SELECT COUNT(*) as codes FROM codes; SELECT COUNT(*) as users FROM users; SELECT COUNT(*) as nicknames FROM nicknames"
/usr/local/bin/mysql -u test -pGim9p6gW test -e "DELETE FROM users WHERE id_ISP  IN (SELECT id from ISPs WHERE name = 'euNetworks Services GmbH');"
/usr/local/bin/mysql -u test -pGim9p6gW test -e "DELETE FROM users where id_code IN (SELECT ID FROM codes WHERE code IN ('m2v', 'ZJ8'));" 
/usr/local/bin/mysql -u test -pGim9p6gW test -e "DELETE FROM users WHERE update_date <= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 28 DAY) AND mysex IN (1,6);"
/usr/local/bin/mysql -u test -pGim9p6gW test -e "DELETE FROM users WHERE id_code IN (SELECT id FROM codes WHERE update_date <= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 18 DAY)) AND mysex IN (1, 6);"
#/usr/local/bin/mysql -u test -pGim9p6gW test -e "DELETE FROM users WHERE id_code IN (SELECT id FROM codes WHERE update_date <= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)) AND mysex IN (2, 7);"
/usr/local/bin/mysql -u test -pGim9p6gW test -e "DELETE FROM codes WHERE id NOT IN (SELECT distinct id_code from users);"
/usr/local/bin/mysql -u test -pGim9p6gW test -e "DELETE FROM nicknames WHERE id NOT IN (SELECT distinct id_mynickname from users);"
/usr/local/bin/mysql -u test -pGim9p6gW test -e "SELECT COUNT(*) as codes FROM codes; SELECT COUNT(*) as users FROM users; SELECT COUNT(*) as nicknames FROM nicknames"
